# This file is distributed under new relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/license for complete details.
# frozen_string_literal: true

require 'logger'

Bundler.require
require 'tasks/newrelic'

task :default => [:before, :during, :after] do
  puts 'default'
end

task :before do
  puts 'before'
end

task :during do
  puts 'during'
end

task :after do
  puts 'after'
end

task :untraced do
  puts 'untraced'
end

task :argument, [:who, :where] => [] do
  puts 'argument'
end

task :boom do
  raise 'a legitimate issue with the proposal.'
end

task :tree => [:branch1, :branch2]
task :branch1 => [:branch1a, :branch1b]
task :branch2 => [:branch2a, :branch2b]
task :branch1a
task :branch1b
task :branch2a
task :branch2b

namespace :named do
  task :all => [:'named:before', :'named:during', :'named:after']

  task :before do
    a = NewRelic::Agent::Tracer.start_segment(name: 'custom_before')
    puts 'named:before'
    a.finish
  end

  task :during do
    a = NewRelic::Agent::Tracer.start_segment(name: 'custom_during')
    puts 'named:during'
    a.finish
  end

  task :after do
    a = NewRelic::Agent::Tracer.start_segment(name: 'custom_after')
    puts 'named:after'
    a.finish
  end
end
